'use strict';

/**
 * @name CreateUserCtrl
 * @author ZYF
 */

angular.module('metalabOperationApp').controller('AvaterModelCtrl', ['$scope', '$stateParams', '$rootScope', '$state', 'params', 'MetaResources', 'MetaRemind', '$uibModalInstance', function($scope, $stateParams, $rootScope, $state, params, MetaResources, MetaRemind, $uibModalInstance) {
    $scope.data = {};
    $scope.data.link = params.data.avater;

    $scope.save = function() {
        MetaResources.user.save({
                'id': params.data.id
            }, {'avatar': $scope.data.link},
            function() {
                MetaRemind.success("恭喜", "保存成功");
                $state.reload();
            },
            function(error) {
                MetaRemind.serverError(error);
            });
        $uibModalInstance.dismiss('cancel');
    };

    $scope.cancel = function() {
        $uibModalInstance.dismiss('cancel');
    };

}]);
